<?php
namespace app\api\controller;
use think\Controller;
use think\Exception;
use think\Request;
use think\File;

class Image extends Controller
{
    public function upload() {
        $file = Request::instance()->file('file');
        // 给定一个目录
        $info = $file->move('upload');
        // print_r($info);die;
        if($info && $info->getPathname()) {
            return $this->result('/'.$info->getPathname(),200);
        }
        else{
            throw new Exception('未找到资源',404);
        }
    }
}